<?php

namespace app\xs_article\controller\web\article;

use app\xs_article\facade\service\CategoryServiceFacade;
use xsframe\base\AdminBaseController;

class Index extends AdminBaseController
{
    protected $tableName = "xs_article_list";

    public function _admin_initialize()
    {
        if (in_array($this->action, ['main', 'add', 'edit'])) {
            $this->result['categorys'] = CategoryServiceFacade::getAll(['uniacid' => $this->uniacid, 'deleted' => 0]);
        }

        $categoryId = $this->params['cateid'];
        if ($categoryId) {
            $this->condition['cateid'] = $categoryId;
        }

        if ($this->request->isAjax()) {
            if (!empty($this->params['showtime']))
                $this->params['showtime'] = strtotime($this->params['showtime']);
        }
    }

    // 选择跳转地址
    public function selectUrl()
    {
        return $this->template('selecturl');
    }
}
